<?
if(!empty($_GET["name"])){
$name = mysql_escape_string($_GET["name"]);
$torrents_name = mysql_query("SELECT * FROM `torrents` WHERE `name` = '$name'") or die(mysql_error());
$data = mysql_fetch_array( $torrents_name );

echo file_get_contents("Js/Menu.js");

echo "<h3><p>";	
echo "<a href=\"/Include/DownloadTorrent.php?id=".$data['id']."\" target=\"_blank\">";
echo "Download ".preg_replace("/_/", " ", $data['name'])."</a></p></h3>\n";

//Skriver NFO
echo "<div onClick=\"sw('sub1');\"><p id=\"P_Hover\">Description</p></div>";
echo "<div id=\"sub1\">";
echo "<textarea cols=\"100\" rows=\"20\" class=\"Info\" readonly=\"yes\">\n".$data['descr']."\n</textarea>\n";
echo "</div>\n";

//Skriver ut filer och storlek

$torrent_data = bdec($data['data']);
$c = count($torrent_data['info']['files']);

echo "<div onClick=\"sw('sub2');\"><p id=\"P_Hover\">Files</p></div>";
echo "<div id=\"sub2\">";
echo "<textarea cols=\"100\" rows=\"10\" readonly=\"yes\" class=\"Info\">\n";
$size_total = 0; 
if ($c > 1) {
	for ($i = 0; $i < $c; $i++) {
		echo "".$torrent_data['info']['files'][$i]['path']['0']." (" . round((($torrent_data['info']['files'][$i]['length'])/1048576),2) . " MB)\n";
		$size_total += round((($torrent_data['info']['files'][$i]['length'])/1048576),2);
	}
} else {
	echo $torrent_data['info']['name'] . '<br>';
}
echo "Total size: ".$size_total." MB";
echo "</textarea>\n";
echo "</div>";






$id = $data['uploaded_by'];
$user_name = mysql_query("SELECT username FROM `accounts` WHERE `id`='$id'") or die(mysql_error());
$data = mysql_fetch_array( $user_name );
echo "<p>Uploaded by:</p>\n";
echo "<p style=\"font-size: 10px;\">".htmlspecialchars($data['uname'])."<p>\n";

echo "<p>Comments:</p>\n";

}else{
echo "<h3>No torrent is specified!</h3>\n";
}
?>